package com.controller;

import com.dao.SpecialityDao;
import com.po.Speciality;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;


@Controller
public class SpecialityController {
    //添加专业
    @RequestMapping(value = "/doAddSpe")
    public String doAddSpe(Speciality speciality, Model model)throws Exception{
       try {
           SpecialityDao U = new SpecialityDao();
           U.addSpecialityTest(speciality);
           model.addAttribute("msg","添加专业成功");
           return "/specialityAdd.jsp";
       } catch (Exception e){
           model.addAttribute("msg",e.getMessage());
           return "/specialityAdd.jsp";
       }
    }
    //查询所有专业
    @RequestMapping(value = "/findSpecialityAll")
    public String doFindId(Model model)throws Exception {
        SpecialityDao specialityDao = new SpecialityDao();
        List<Speciality> speciality = specialityDao.FindSpecAll();
        model.addAttribute("cs",speciality);
        return "/vetadd.jsp";
    }

    //添加医生后跳转查询所有专业
    @RequestMapping(value = "/doAddVetForFind")
    public String doFind(Model model)throws Exception {
        SpecialityDao specialityDao = new SpecialityDao();
        List<Speciality> speciality = specialityDao.FindSpecAll();
        model.addAttribute("cs",speciality);
        model.addAttribute("msg","添加成功");
        return "/vetadd.jsp";
    }
}
